package www.openteam.com.presenter.qualityCntrl;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.FQCBadItem;
import www.openteam.com.bean.FQCCheckItem;
import www.openteam.com.bean.FQCCheckMan;
import www.openteam.com.bean.FQCCrMaMi;
import www.openteam.com.bean.FQCGoodsField;
import www.openteam.com.bean.FQCGoodsInspect;
import www.openteam.com.bean.FQCHalfGoodsInspect;
import www.openteam.com.bean.FQCSamplePlan;
import www.openteam.com.contract.qualityCntrl.FQCContract;
import www.openteam.com.model.qualityCntrl.FQCModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.qualityCntrl.FQCFragment;

/**
 * Created by Administrator on 2018/3/23 0023.
 */

public class FQCPresenter extends BasePresenter<FQCFragment>
implements FQCContract.FQCPresenter{

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new FQCModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("FQCModel", models[0]);
        return hashMap;
    }

    @Override
    public void findGoodsFeild() {
        ((FQCModel)getiModelMap().get("FQCModel")).findGoodsYeild(new FQCModel.GoodsYeildListener() {
            @Override
            public void success(FQCGoodsField data) {
                getIView().findGoodsFeildSuccess(data);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findGoodsInspect() {
        ((FQCModel)getiModelMap().get("FQCModel")).findFQCGoodsInspect(new FQCModel.GoodsInspectListener() {
            @Override
            public void success(FQCGoodsInspect data) {
                getIView().findGoodsInspectSuccess(data);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findHalfGoodsInspect() {
        ((FQCModel)getiModelMap().get("FQCModel")).findFQCHalfGoodsInspect(new FQCModel.HalfGoodsInspectListener() {
            @Override
            public void success(FQCHalfGoodsInspect data) {
                getIView().findHalfGoodsInspectSuccess(data);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findSamplePlan(int storage) {
        ((FQCModel)getiModelMap().get("FQCModel")).findSamplePlan(storage, new FQCModel.SamplePlanListener() {
            @Override
            public void success(FQCSamplePlan fqcSamplePlan) {
                getIView().findSamplePlan(fqcSamplePlan);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findSamplePlanResult(int storage, String code) {
        ((FQCModel)getiModelMap().get("FQCModel")).findSamplePlanResult(storage,code, new FQCModel.SamplePlanResultListener() {
            @Override
            public void success(FQCSamplePlan fqcSamplePlan) {
                getIView().findSamplePlanResult(fqcSamplePlan);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findElement(int element, int checkNum, final String mark) {
        ((FQCModel)getiModelMap().get("FQCModel")).findElement(checkNum, element, new FQCModel.ElementListener() {
            @Override
            public void success(FQCCrMaMi fqcCrMaMi) {
                getIView().findElement(fqcCrMaMi,mark);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findCheckItem() {
        ((FQCModel)getiModelMap().get("FQCModel")).findCheckItem(new FQCModel.CheckItemListener() {
            @Override
            public void success(FQCCheckItem fqcCheckItem) {
                getIView().findCheckItem(fqcCheckItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findCheckMan() {
        ((FQCModel)getiModelMap().get("FQCModel")).findFQCCheckMan(new FQCModel.CheckManListener() {
            @Override
            public void success(FQCCheckMan data) {
                getIView().findCheckMan(data);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findBadItem(String code) {
        ((FQCModel)getiModelMap().get("FQCModel")).findBadItem(code, new FQCModel.BadItemListener() {
            @Override
            public void success(FQCBadItem fqcBadItem) {
                getIView().findBadItem(fqcBadItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }
}
